/**
 * @desc index
 * @author DragonTeam <https://www.bpmport.com>
 * @since 2024/11/7 14:31
 */
import { moddle } from '@/bpmn-moddle'
import { capitalize } from '@/utils/tools'
import type { BpmnModdleElement } from '@/types/bpmn-node'

export function createElement<T extends BpmnModdleElement = BpmnModdleElement>(type: string, props?: Record<string, any>): T {
  if (type.includes(':')) {
    return moddle.create(type, props)
  }
  return moddle.create(`flowable:${capitalize(type)}`, props)
}
